var dataList = null;
function init(){
	initData(afterInitData);
}

function afterInitData(list){
	dataList = list;
	
	var con = '',j;
	for(var i = 0;i<dataList.length;i++){
		var data = dataList[i];
		j = i + 1;
		con += '<div class="item"><a href="#" tar="'+j+'">'+data.name+'</a></div>';
	}
	
	var itemBox = document.getElementById('itemBox');
	itemBox.innerHTML = con;
	var aList = itemBox.getElementsByTagName('a');
	var a;
	for(var i = 0;i<aList.length;i++){
		a = aList[i];
		a.onfocus = focusItem;
		a.onclick = clickItem;
		a.onblur = blurItem;
	}
	aList[0].focus();
}

function focusItem(event){
	var a = event.currentTarget;
	var par = a.parentNode;
	par.className = 'focusItem';
}

function blurItem(event){
	var a = event.currentTarget;
	var par = a.parentNode;
	par.className = 'item';
}

function clickItem(event){
	var a = event.currentTarget;
	var tar = parseInt(a.getAttribute("tar"));
	var data = dataList[tar - 1];
	$.gotoPage(data.url);
}